#include "rcc.h"

void rcc_init()
{
	RCC_CR |= (1<<16);
	
	while(!(RCC_CR & (1 << 17)));
	
	RCC_PLLCFGR = (RCC_PLLCFGR & (~(0x3F))) | (25<<0);//25
	RCC_PLLCFGR = ((RCC_PLLCFGR & (~(0x1FF<<6))) | (336 << 6));//336
	RCC_PLLCFGR = (RCC_PLLCFGR & (~(0x3<<16)));//2
	
	RCC_PLLCFGR |= 1 << 22;
	
	RCC_CR |= 1 << 24;
	
	
	while(!RCC_CR & (1 << 25));
	
	FLASH_ACR &= (~(7<<0));
	FLASH_ACR |= (5 << 0);
	FLASH_ACR |= (7 << 8);
	
	RCC_CFGR &= (0x0 << 4);
	
	RCC_CFGR |= (2<<0);
	RCC_CFGR &= ~(1<<0);
	while(((RCC_CFGR & (3<<2)) !=8)); 
}

